package com.test.ai.config;

import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.memory.InMemoryChatMemory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * Created with IntelliJ IDEA.
 *
 * @description:
 * @author: liuziyang
 * @since: 8/20/25 4:06 PM
 * @modifiedBy:
 * @version: 1.0
 */
@Configuration
public class MemoryConfig {
  /**
   * Chat memory chat memory.
   *
   * @return the chat memory
   */
  @Primary
  @Bean("inMemory")
  public ChatMemory chatMemory() {
    return new InMemoryChatMemory();
  }

  /**
   * Message chat memory advisor message chat memory advisor.
   *
   * @return the message chat memory advisor
   */
  @Primary
  @Bean("inMemoryAdvisor")
  public MessageChatMemoryAdvisor messageChatMemoryAdvisor() {
    return new MessageChatMemoryAdvisor(chatMemory());
  }
}
